﻿using System;
using Microsoft.SharePoint;

namespace Xodeuz.SP.Common
{
    public class ListCreationService
    {
        public static void CreateList(Type listDefinition, String url, bool force, bool elevatedPermissions)
        {
            var type = listDefinition.GetType();
            var attribute = (SharePointList)ReflectionService.GetListDefinitionAttribute(type);
            attribute.EnsureList(url, force, elevatedPermissions);
        }

        public static void CreateList(Type listDefinition, String url, bool force)
        {
            CreateList(listDefinition, url, force, false);
        }

        public static void CreateList(Type listDefinition, bool force)
        {
            CreateList(listDefinition, SPContext.Current.Web.Url, force, false);
        }

        public static void CreateList(Type listDefinition)
        {
            CreateList(listDefinition, SPContext.Current.Web.Url, false, false);
        }
    }
}
